win32: Fix modal_hint handling
authorAlexander Larsson <alexl@redhat.com>
Thu, 27 Oct 2011 20:13:54 +0000 (22:13 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 10 Nov 2011 16:41:07 +0000 (17:41 +0100)
Modal hints are not really a stack. All windows that are modal
are allowed to get input, not just the top one.

This fixes bug #604156

gdk/win32/gdkevents-win32.c
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkwindow-win32.c

index 49741666affa6fdd5bdf503e0f81bfb17c623762..4f5aa62c1b923057a6a9b86749a50dec0f34911e 100644 (file)
@@ -104,8 +104,6 @@ static gboolean gdk_event_dispatch (GSource     *source,
                                    GSourceFunc  callback,
                                    gpointer     user_data);
 
-static gboolean is_modally_blocked (GdkWindow   *window);
-
 /* Private variable declarations
  */
 
@@ -2571,15 +2569,10 @@ gdk_event_translate (MSG  *msg,
             return_val = TRUE;
           }
 
-        tmp = _gdk_modal_current ();
-
-        if (tmp != NULL)
+        if (_gdk_modal_blocked (gdk_window_get_toplevel (window)))
           {
-            if (gdk_window_get_toplevel (window) != tmp)
-              {
-                *ret_valp = MA_NOACTIVATEANDEAT;
-                return_val = TRUE;
-              }
+            *ret_valp = MA_NOACTIVATEANDEAT;
+            return_val = TRUE;
           }
        }
 
@@ -3244,7 +3237,7 @@ gdk_event_translate (MSG  *msg,
        * but we still need to deal with alt-tab, or with SetActiveWindow() type
        * situations.
        */
-      if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
+      if (_gdk_modal_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
        {
          GdkWindow *modal_current = _gdk_modal_current ();
          SetActiveWindow (GDK_WINDOW_HWND (modal_current));
@@ -3408,10 +3401,3 @@ gdk_win32_set_modal_dialog_libgtk_only (HWND window)
 {
   modal_win32_dialog = window;
 }
-
-static gboolean
-is_modally_blocked (GdkWindow *window)
-{
-  GdkWindow *modal_current = _gdk_modal_current ();
-  return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
-}
index d7dae478584e3da5a306d0fa7fc2834ff37330f8..7456de21f7ecb0c318818b48205eecbbaa0c9919 100644 (file)
@@ -187,7 +187,7 @@ void    _gdk_dropfiles_store (gchar *data);
 void       _gdk_push_modal_window   (GdkWindow *window);
 void       _gdk_remove_modal_window (GdkWindow *window);
 GdkWindow *_gdk_modal_current       (void);
-
+gboolean   _gdk_modal_blocked       (GdkWindow *window);
 
 #ifdef G_ENABLE_DEBUG
 gchar *_gdk_win32_color_to_string      (const GdkColor *color);
index 68d58c0cc415e1a3aa116c191456271e4c4eb279..035bb4b59358b3c86da3246c4689755a2c28422e 100644 (file)
@@ -1780,24 +1780,40 @@ _gdk_remove_modal_window (GdkWindow *window)
     }
 }
 
-GdkWindow *
-_gdk_modal_current (void)
+gboolean
+_gdk_modal_blocked (GdkWindow *window)
 {
-  if (modal_window_stack != NULL)
+  GSList *l;
+  gboolean found_any = FALSE;
+
+  for (l = modal_window_stack; l != NULL; l = l->next)
     {
-      GSList *tmp = modal_window_stack;
+      GdkWindow *modal = l->data;
 
-      while (tmp != NULL && !GDK_WINDOW_IS_MAPPED (GDK_WINDOW (tmp->data)))
-       {
-         tmp = g_slist_next (tmp);
-       }
+      if (modal == window)
+       return FALSE;
 
-      return tmp != NULL ? tmp->data : NULL;
+      if (GDK_WINDOW_IS_MAPPED (modal))
+       found_any = TRUE;
     }
-  else
+
+  return found_any;
+}
+
+GdkWindow *
+_gdk_modal_current (void)
+{
+  GSList *l;
+
+  for (l = modal_window_stack; l != NULL; l = l->next)
     {
-      return NULL;
+      GdkWindow *modal = l->data;
+
+      if (GDK_WINDOW_IS_MAPPED (modal))
+       return modal;
     }
+
+  return NULL;
 }
 
 static void